import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './pages/app'
let stateArr = []// 放传进来的每一个变量的 ["zhangsn","10"]
let count = 0
const root = ReactDOM.createRoot(document.getElementById('root'));
export let my_usestate = (props)=>{
     let creeateIndex = count
     //  stateArr[creeateIndex] 已经存在了那就用他已经存在的值，那如果不存在，说明第一次声明，用传递进来的参数
     stateArr[creeateIndex] =  stateArr[creeateIndex]?  stateArr[creeateIndex] : props
     // 这个函数最终返回一个数组
     function setProps (newProps) {
         alert(creeateIndex,11111);
      stateArr[creeateIndex] = newProps
     
      count = 0
      root.render(
        <App />
    );
     
     }
     count ++ 
   
     return [stateArr[creeateIndex],setProps] // 返回一个数组，数组是复杂数据类型，复杂数据类型是存在堆内存的
}

root.render(
 
    <App />
 
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals

